#!/usr/bin/perl -w
use strict;
use Getopt::Long;

#88888888888888888888888888888888888888888888888888888888888888888888888888888888

#	Usage

#88888888888888888888888888888888888888888888888888888888888888888888888888888888

my $usage = <<'USAGE';

USAGE:

    list1_minus_list2.pl list1.file list2.file > list1_minus_2.file

	Takes two lists.
	Ouputs what is in list 1 and not in list 2
	Prints to STDOUT
USAGE


#88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888

#	Get options

#88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
# optional parameters
my $verbose;
my $help;
GetOptions(
			'help'						=> \$help);

die $usage if ($help);
die $usage unless (@ARGV == 2);


my @ids1;
{
	open FILE1, $ARGV[0] or die
		"Error:\n\tCould not open $ARGV[0]\n";
	my %ids1;
	print STDERR "Reading $ARGV[0]...\n";
	for (<FILE1>)
	{
		chomp;
		$ids1{$_} = 1;
	}
	@ids1 = keys %ids1;
}

print STDERR "Reading $ARGV[1]...\n";
my %ids2;
open FILE2, $ARGV[1] or die
	"Error:\n\tCould not open $ARGV[1]\n";
for (<FILE2>)
{
	chomp;
	$ids2{$_} = 1;
}

print STDERR scalar @ids1, "\tidentifiers in $ARGV[0]\n";
print STDERR scalar keys %ids2, "\tidentifiers in $ARGV[1]\n";
my ($cnt_same,  $cnt_diff) = (0,0);
for (@ids1)
{
	if (!exists($ids2{$_}))
	{
		print $_, "\n";
		++$cnt_diff;
	}
	else
	{
		++$cnt_same;
	}
}

print STDERR "$cnt_same\tidentifiers were shared.\n";
print STDERR "$cnt_diff\tidentifiers were unique to $ARGV[0].\n";
